// extract module
var http = require('http');

// use module
http.createServer(function(request, response) {
	// extract and split cookies
	var cookie = request.headers.cookie;
	cookie = cookie.split(';').map(function(elements) {
		var element = elements.split('=');
		return {
			key: element[0],
			value: element[1]
		};
	});
	
	// create cookie
	response.writeHead(200, {
		'Content-Type': 'text/html',
		'Set-Cookie': ['name = Sejoon', 'region = Seoul']
	});
	
	// GET Request
	response.end('<h1>' + JSON.stringify(cookie) + '</h1>');
}).listen(52273, function() {
	console.log('Server running at http://127.0.0.1:52273');
});